package mole.hud 
{
	import mole.Main;
	import net.flashpunk.Entity;
	import net.flashpunk.graphics.Text;
	/**
	 * ...
	 * @author Cédric Liaudet
	 */
	public class CStamina
	{			
		public function CStamina(_iNb:int, _nPosX:int)
		{
			m_aStamina = new Array;
			for (var i:int = 0; i < 4; i++)			
				m_aStamina.push(new CGraphicStamina(_nPosX + 32, i));
			Text.size = 16;			
			m_Text = new Text("P" + (_iNb + 1) + ":", _nPosX, 390);
			m_Text.color = 0xFFFFFFFF;			
		}
		
		public function Init():void
		{
			for (var i:int = 0; i < 4; i++)
				m_aStamina[i].Init();
				
			Main.World.addGraphic(m_Text);
		}
		
		public function SetStamina(_nStamina:Number):void
		{
			var i:int = 0;
			if (_nStamina == 0)
			{
				for (i = 0; i < 4; i++)
					m_aStamina[i].visible = false;
			}
			else if (_nStamina < 25)
			{		
				m_aStamina[0].visible = true;
				
				for (i = 1; i < 4; i++)
					m_aStamina[i].visible = false;
			}
			else if (_nStamina < 50)
			{
				for (i = 0; i < 2; i++)
					m_aStamina[i].visible = true;
				
				m_aStamina[2].visible = false;
				m_aStamina[3].visible = false;
			}
			else if (_nStamina < 75)
			{
				for (i = 0; i < 3; i++)
					m_aStamina[i].visible = true;
				
				m_aStamina[3].visible = false;
			}
			else if(_nStamina <= 100)
			{
				for (i = 0; i < 4; i++)
					m_aStamina[i].visible = true;
			}
		}
		
		private var m_aStamina:Array;
		private var m_Text:Text;
	}	
}